﻿using System;
using System.Collections.Generic;
using System.Text;
using T.FAS.Runtime.DataAccess.Kernel;
using T.FAS.Runtime.DataAccess.SPI;
using T.FAS.Runtime.Metadata.Entity.DataModel;
using T.FAS.Runtime.DataAccess.SQLDom;
using T.FAS.Runtime.Base.Entity;

namespace T.FAS.Runtime.DataAccess.Engine
{
    interface ICDOSQLBuilder
    {
        #region 新增
        /// <summary>
        /// 解析生成Insert语句。
        /// </summary>       
        /// <param name="CompositeDataObject">领域模型。</param>
        /// <param name="instance">要插入的数据。</param>        
        /// <returns>Insert语句集合。</returns>
        SqlStatementCollection ParseInsertSql(CompositeDataObject CompositeDataObject, TRecord instance, SqlExecuteControlContext context = null);

        /// <summary>
        /// 解析生成指定领域对象的Insert语句。
        /// </summary>
        /// <param name="CompositeDataObject">通用中间对象</param>
        /// <param name="CompositeNodeObject">节点对象</param>
        /// <param name="instance">要插入的数据</param>        
        /// <returns>指定领域对象的Insert语句</returns>
        SqlStatementCollection ParseInsertSql(CompositeDataObject CompositeDataObject, CompositeNodeObject CompositeNodeObject, TRecord instance, SqlExecuteControlContext context = null);
        #endregion

        #region 查询
        /// <summary>
        /// 解析生成查询SQL
        /// </summary>
        /// <remarks>按主键数据作为查询依据</remarks>
        /// <param name="CompositeDataObject">领域模型</param>        
        /// <param name="dataID">主键数据</param>        
        /// <returns>查询SQL</returns>
        SqlStatementCollection ParseQuerySqlByID(CompositeDataObject CompositeDataObject, string dataID, SqlExecuteControlContext context = null);

        /// <summary>
        /// 解析生成查询SQL
        /// </summary>
        /// <remarks>按主键数据作为查询依据</remarks>
        /// <param name="CompositeDataObject">领域模型</param>            
        /// <param name="CompositeNodeObject">领域对象</param>        
        /// <param name="dataID">主键数据</param>        
        /// <returns>查询SQL</returns>
        SqlStatementCollection ParseQuerySqlByID(CompositeDataObject CompositeDataObject, CompositeNodeObject CompositeNodeObject, string dataID, SqlExecuteControlContext context = null);

        /// <summary>
        /// 解析生成查询SQL
        /// </summary>
        /// <param name="CompositeDataObject">领域模型</param>        
        /// <param name="filter">过滤器</param>
        /// <returns>查询SQL</returns>
        [Obsolete]
        SqlStatementCollection ParseQuerySqlByFilter(CompositeDataObject CompositeDataObject, QueryFilter filter, SqlExecuteControlContext context = null);

        /// <summary>
        /// 解析生成查询SQL
        /// </summary>
        /// <remarks>按主键数据作为查询依据</remarks>
        /// <param name="CompositeDataObject">领域模型</param>            
        /// <param name="CompositeNodeObject">领域对象</param>               
        /// <param name="filter">过滤器</param>
        /// <returns>查询SQL</returns>
        [Obsolete]
        SqlStatementCollection ParseQuerySqlByFilter(CompositeDataObject CompositeDataObject, CompositeNodeObject CompositeNodeObject, QueryFilter filter, SqlExecuteControlContext context = null);
        #endregion

        #region 删除
        /// <summary>
        /// 解析生成删除SQL
        /// </summary>
        /// <remarks>按主键数据作为查询依据</remarks>
        /// <param name="CompositeDataObject">领域模型</param>        
        /// <param name="dataID">主键数据</param>        
        /// <returns>删除SQL</returns>
        SqlStatementCollection ParseDeleteSqlByID(CompositeDataObject CompositeDataObject, string dataID, SqlExecuteControlContext context = null);

        /// <summary>
        /// 解析生成删除SQL
        /// </summary>
        /// <remarks>按主键数据作为查询依据</remarks>
        /// <param name="CompositeDataObject">领域模型</param> 
        /// <param name="CompositeNodeObject">领域对象</param>
        /// <param name="dataID">主键数据</param>        
        /// <returns>删除SQL</returns>
        SqlStatementCollection ParseDeleteSqlByID(CompositeDataObject CompositeDataObject, CompositeNodeObject CompositeNodeObject, string dataID, SqlExecuteControlContext context = null);
        #endregion

        #region 更新
        /// <summary>
        /// 解析生成Update语句。
        /// </summary>       
        /// <param name="CompositeDataObject">领域模型。</param>
        /// <param name="instance">要更新的数据。</param>        
        /// <returns>Update语句集合。</returns>
        SqlStatementCollection ParseUpdateSql(CompositeDataObject CompositeDataObject, TRecord data, SqlExecuteControlContext context = null);

        /// <summary>
        /// 解析生成Update语句。
        /// </summary>       
        /// <param name="CompositeDataObject">领域模型。</param>
        /// <param name="instance">要更新的数据。</param>        
        /// <returns>Update语句集合。</returns>
        SqlStatementCollection ParseUpdateSql(CompositeDataObject CompositeDataObject, CompositeNodeObject momainObject, TRecord data, SqlExecuteControlContext context = null);
        #endregion
    }
}
